<template>
	<view class="takeRecord">
		<mescroll-uni ref="mescrollRef" :isBack="true" @init="mescrollInit" height="100%" :top="mescrollUni_Top" :bottom="mescrollUniBottom" :total="total" :down="downOption" @down="downCallback" :up="upOption" @up="upCallback" @emptyclick="emptyClick">
			<view class="takeRecord-box">
				<view class="takeRecord-box-li" v-for="item,index in list" :key="index">
					<view class="takeRecord-box-li-money"><text>+{{item.orderPrice}}</text></view>
					<view class="takeRecord-box-li-main">
						<view class="takeRecord-box-li-main-left"><text>提现账号 : {{item.targetId}}</text></view>
						<view class="takeRecord-box-li-main-right record_a" v-if="item.orderState == 1"><text>提现成功</text></view>
						<view class="takeRecord-box-li-main-right record_b" v-if="item.orderState === 0"><text>提现中</text></view>
						<view class="takeRecord-box-li-main-right record_c" v-if="item.orderState == 2"><text>提现失败</text></view>
					</view>
					<view class="takeRecord-box-li-time"><text>提现时间 : </text><text>{{item.createTime}}</text></view>
				</view>
			</view>
		</mescroll-uni>
	</view>
</template>

<script>
	import MescrollMixin from "@/components/mescroll-uni/mescroll-mixins.js";
	import MescrollMoreItemMixin from "@/components/mescroll-uni/mixins/mescroll-more-item.js";
	export default {
		mixins: [MescrollMixin,MescrollMoreItemMixin], // 注意此处还需使用MescrollMoreItemMixin (必须写在MescrollMixin后面)
		data() {
			return {
				total:0,
				list:[],
				params:{
					page:1,
					pageSize:8,
				},
				downOption:{
					auto:false // 不自动加载 (mixin已处理第一个tab触发downCallback)
				},
				upOption:{
					auto:false, // 不自动加载
					page: {
						num: 0, // 当前页码,默认0,回调之前会加1,即callback(page)会从1开始
						size: 10 // 每页数据的数量
					},
					noMoreSize: 6, //如果列表已无数据,可设置列表的总数量要大于半页才显示无更多数据;避免列表数据过少(比如只有一条数据),显示无更多数据会不好看; 默认5
					toTop:{
						offset:400,
					},
					empty:{
						tip: '~ 空空如也 ~', // 提示
						btnText: ''
					},
					elItem:{
						top:256,
						height:265,
						rowNum:2,
					}
				},
				mescrollUni_Top:0,
				mescrollUniBottom:0,
			}
		},
		mounted() {
			this.mescroll.setPageNum(1)
			this.mescroll.resetUpScroll(true)
			this.mescroll.scrollTo(0,300)
		},
		methods: {
			/*下拉刷新的回调 */
			downCallback() {
				// 这里加载你想下拉刷新的数据, 比如刷新轮播数据
				// loadSwiper();
				// 下拉刷新的回调,默认重置上拉加载列表为第一页 (自动执行 page.num=1, 再触发upCallback方法 )
				this.mescroll.resetUpScroll()
			},
			/*上拉加载的回调: 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10 */
			upCallback(page) {
				// console.log(page.num)
				this.params.page = page.num
				this.getList()
			},
			//点击空布局按钮的回调
			emptyClick(){
				uni.showToast({
					title:'点击了按钮,具体逻辑自行实现'
				})
			},
			getList(){
				this.mescroll.lockUpScroll(true)
				this.$api.myWithdraw(this.params).then(res => {
					console.log(res)
					let curLen = this.list.length
					let totalPage
					if(res.code == 200){
						if(this.params.page == 1) this.list = []
						this.list = this.list.concat(res.data.records)
						curLen = this.list.length
						totalPage = Math.ceil(res.data.total / this.params.pageSize)
						setTimeout(() => {
							this.mescroll.endByPage(curLen, totalPage);
						},200)
						this.total = res.data.total
					}
					// console.log(this.upOption.toTop)
					// this.mescroll.endSuccess(curLen)
					setTimeout(() => {
						this.mescroll.lockUpScroll(false)
					},800)
				},err => {
					setTimeout(() => {
						this.mescroll.lockUpScroll(false)
					},800)
					this.mescroll.endErr()
				})
			},
		}
	}
</script>

<style lang="less">
	.takeRecord{
		width: 100%;
		min-height: 100vh;
		background-color: #16181D;
		font-family: PingFangSC-Medium, PingFang SC, '微软雅黑';
		font:caption;
		.takeRecord-box{
			padding: 0 48rpx;
			box-sizing: border-box;
			.takeRecord-box-li{
				border-bottom: 1px solid #262A34;
				padding-bottom: 32rpx;
				.takeRecord-box-li-money{
					padding-top:48rpx;
					// height: 40rpx;
					font-size: 36rpx;
					font-family: PingFangSC-Medium, PingFang SC, '微软雅黑';
					font-weight: 500;
					color: #FFFFFF;
					line-height: 40rpx;
				}
				.takeRecord-box-li-main{
					display: flex;
					justify-content: space-between;
					padding-top: 14rpx;
					.takeRecord-box-li-main-left{
						width: 412rpx;
						height: 48rpx;
						font-size: 28rpx;
						font-family: PingFangSC-Medium, PingFang SC, '微软雅黑';
						color: #5D5F7A;
						line-height: 48rpx;
					}
					.takeRecord-box-li-main-right{
						font-size: 32rpx;
						height: 48rpx;
						line-height: 48rpx;
						font-family: PingFangSC-Medium, PingFang SC, '微软雅黑';
					}
					.record_a{color: #A06AF9;}
					.record_b{color: #F98B6A;}
					.record_c{color: rgba(255, 255, 255, 0.4);}
				}
				.takeRecord-box-li-time{
					height: 48rpx;
					font-size: 28rpx;
					font-family: PingFangSC-Medium, PingFang SC, '微软雅黑';
					color: #5D5F7A;
					line-height: 48rpx;
				}
			}
		}
	}
</style>
